package com.fzhucc.modules.lesson.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
* @description /
* @author yyg
* @date 2022-12-08
**/
@Entity
@Data
@Table(name="tb_lesson_second_chapter")
public class LessonSecondChapter implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "`first_chapter_id`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "一级列表id")
    private Integer firstChapterId;

    @Column(name = "`url`")
    @ApiModelProperty(value = "内容")
    private String url;

    @Column(name = "`type`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "分类 视频、文档、图片")
    private String type;

    @Column(name = "`name`")
    @ApiModelProperty(value = "名称")
    private String name;

    public void copy(LessonSecondChapter source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
